﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.Meeting;
using Enterprise.Service.Meeting;
using Enterprise.Control;
namespace Enterprise.UI.Web.Modules.Meeting
{
    public partial class CheckIndex : Enterprise.Service.BasePage
    {
        int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        string Cmd = (string)Utility.sink("Cmd", Utility.MethodType.Get, 0, 0, Utility.DataType.Str);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
                BindGrid1();
            }
        }
        private void OnStart()
        {
            if (!string.IsNullOrEmpty(Cmd) &&Cmd=="qs"&& Id != 0)
            {
                string _note = "签收成功, 请准时参加会议！";
                try
                {
                    MeetingRecevieService mrService = new MeetingRecevieService();
                    MeetingRecevieEntity entity = new MeetingRecevieEntity();
                    entity.MID = Id;
                    entity.MRUSERID = Utility.Get_UserId;
                    entity.MRTIME = DateTime.Now;
                    entity.DB_Option_Action = "Insert";
                    mrService.MeetingRecevieExecute(entity);
                }
                catch (Exception ex)
                {
                    _note = ex.Message;
                }
                Utility.ShowMsg(this.Page, "OK", this.Tran(_note), "CheckIndex.aspx");
            }
        }

        private void BindGrid1()
        {
            MeetingService mService = new MeetingService();
            var meetinglist = mService.MeetingUnCheck(Utility.Get_UserId).OrderByDescending(p => p.MCreateTime).ToList();
            GridView1.DataSource = meetinglist;
            GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindGrid1();
        }

    }
}